<template>
      <a-modal :title="title" :width="600" class="custom-modal" @cancel="visible=false" :visible="visible" :footer="null">
        <div style="padding: 30px;">
            <a-alert
                  description="审核通过，更新状态为待开票。不通过需要填写理由，更新状态为驳回"
                  type="info"
                  show-icon 
                  style="margin-bottom: 10px"
                  closable/>
            <a-textarea v-model="remark" :rows="4" placeholder="请输入拒绝理由"/>
        </div>
        <div class="ant-modal-footer">
            <a-button @click="visible=false" type="primary">取消</a-button>
            <a-button type="danger" @click="handleCmbSubmit(4)">拒绝</a-button>
            <a-button type="primary" @click="handleCmbSubmit(3)">审核通过</a-button>
        </div>
      </a-modal>
</template>
<script>
import { 
  billingOperate
} from '@/api/manage/billing'
export default {
  name: 'invoiceApply',
  data () {
    return {
        title:'开票审核',
        visible:false,
        remark:'',
        id:'',
        category:'',
        type:''
    }
  },
  methods:{
    add(item){
        this.id = item.id;
        this.category = item.category;
        this.type = item.type;
        this.visible = true;
    },
    async handleCmbSubmit(status){
        let params = {};
        if(status === 4 && !this.remark){
            return this.$message.error('请填写拒绝理由！');
        }
        params.id = this.id;
        params.type = this.type;
        params.category = this.category;
        params.remark = this.remark;
        params.status = status;
        const {code} =  await billingOperate(params);
        if(code === '1'){
            this.$message.success('操作成功');
            this.visible = false;
            this.$emit("ok");
        }
       
    }
  }
}
</script>
